<template>
  <div>
      <h1></h1>
    <van-row>
        
        <van-col span="6"> <celan/> </van-col>
        <van-col span="18"> <sellheader/> 
        <div style="padding-left: 0px;">
            <van-row>
          <van-col span="2">
            <van-button type="info" @click="add_show">新增</van-button>
          </van-col>
          <van-col span="2">
            <van-button disabled type="primary" @click="exporta">导出</van-button>
          </van-col>
          <van-col span="2">
            <van-uploader :after-read="afterRead" multiple accept=".xls">导入</van-uploader>
          </van-col>
        </van-row>

            <el-tree :data="list" :props="defaultProps" @node-click="handleNodeClick" />
        </div>
        </van-col>
    </van-row>
  </div>
</template>

<script>
import myaxios from "axios";
import sellheader from './sellheader.vue'
import celan from './celan_zi.vue'
export default {
    components:{
        sellheader,
        celan
    },
    data() {
    return {
      list: [
        {
          name: this.list,
          son: [
            {
              name: this.list,
              son: [
                {
                  label: this.list,
                },
              ],
            },
          ],
        },
      ],
      defaultProps: {
        children: 'son',
        label: 'name',
      },
    }
  },
  methods: {
    handleNodeClick(list) {
      console.log(list)
    },
    afterRead(file){
      let formdate = new FormData()
      formdate.append('file',file.file)
      console.log(formdate)
      myaxios({url:'http://127.0.0.1:5000/upload',method:'post',data:formdate}).then(res=>{
        alert(res.data.msg)
      })
    },
    exporta(){
      myaxios({url:'http://127.0.0.1:5000/download',method:'get'}).then(res=>{
        console.log(res)
      })
    },
    sele(){
      myaxios({url:'http://127.0.0.1:5000/oran',method:'get'}).then(res=>{          
        console.log(res.data)
        this.list = res.data.list
      })
    }
  },
  mounted(){
      this.sele()
  }

}
</script>

<style>

</style>